package own.stu.jobgib.playown.basic;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class BreakIf {

    private static Logger logger = LoggerFactory.getLogger(BreakIf.class);

    public static void main(String[] args) {

        AltResult result = new AltResult(null);
        testBreakIf(result);

        System.out.println(" ============  ");

        result = new AltResult(new RuntimeException("xxx"));
        testBreakIf(result);
    }

    static final class AltResult { // See above
        final Throwable ex;        // null only for NIL

        AltResult(Throwable x) {
            this.ex = x;
        }
    }

    private static boolean testBreakIf(AltResult result) {

        Throwable x;

        tryComplete:
        if (1 == 1) {
            if (result instanceof AltResult) {
                if ((x = result.ex) != null) {
                    logger.error("ex: {}", x);
                    break tryComplete;
                }
                logger.info("result: {}", x);
            }
            logger.info("-------");
        }
        return true;
    }
}
